﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace MediaServer.Client
{
    public partial class MediaPlayback : Form
    {

        /// <summary>
        /// Extensions supported by Windows Media Player COM Component
        /// </summary>
        private List<string> wmpExts = new List<string>(){
            ".asf", ".wma", ".wmv", ".wm", ".asx", ".wax", ".wvx", ".wpl", ".dvr-ms", ".wmd", ".avi", 
            ".mpg", ".mpeg", ".m1v", ".mp2", ".mp3", ".mpa", ".mpe", ".mpv2", ".m3u", ".mid", ".midi", 
            ".rmi", ".aif", ".aifc", ".aiff", ".au", ".snd", ".wav", ".cda", ".ivf", ".wmz", ".wms", 
            ".mov", ".qt"
        };

        public MediaPlayback()
        {
            InitializeComponent();

        }

        public void Play(string URL)
        {
            if (wmpExts.Contains(Path.GetExtension(URL)))
            {
                pictureBox.Hide();
                axWindowsMediaPlayer.Show();
                axWindowsMediaPlayer.URL = URL;
                axWindowsMediaPlayer.Ctlcontrols.play();
            }
            else if (true)
            {
                pictureBox.Show();
                pictureBox.Load(URL);
                axWindowsMediaPlayer.Hide();
                axWindowsMediaPlayer.Ctlcontrols.stop();
            }

        }
    }
}
